<!DOCTYPE html>
<html>
<head>
    <title>查看</title>
    <meta charset="UTF-8">
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap.css" />
    <link rel="stylesheet" type="text/css" href="../Css/bootstrap-responsive.css" />
    <link rel="stylesheet" type="text/css" href="../Css/style.css" />
    <script type="text/javascript" src="../Js/jquery.js"></script>
    <script type="text/javascript" src="../Js/bootstrap.js"></script>
    <script type="text/javascript" src="../Js/ckform.js"></script>
    <script type="text/javascript" src="../Js/common.js"></script>
    <script type="text/javascript" src="../Js/ckeditor/ckeditor.js"></script>
 

    <style type="text/css">
        body {
            padding-bottom: 40px;
        }
        .sidebar-nav {
            padding: 9px 0;
        }

        @media (max-width: 980px) {
            /* Enable use of floated navbar text */
            .navbar-text.pull-right {
                float: none;
                padding-left: 5px;
                padding-right: 5px;
            }
        }


    </style>
    <script type="text/javascript">
	// 地址栏获取id
	let hosrId = document.location.toString().GetValue("hosrId");
	// 查询填充信息
	function queryMsg(){
		layer.load(0)
		$.ajax({
		    type: "GET",
		    // 1. url请求地址前加后端API地址origin
		    url: origin + "/register/" + hosrId,
		    data: {jwtToken:jwtToken},
		    dataType: "json",
		    // 2. 允许携带cookie跨域请求
		    xhrFields: {
		        withCredentials: true
		    },
		    crossDomain: true,
		    success: function (data) {
				console.log(data.obj)
				layer.closeAll();
				let guahao = data.obj;
				if(data.code == 200){
					// 填充姓名
					$("td[name='hosrName']").text(guahao.hosrName);
					// 填充身份证
					$("td[name='hosrIdcar']").text(guahao.hosrIdcar)
					// 填充挂号费
					$("td[name='hosrRegPrice']").text(guahao.hosrRegPrice + "元");
					// 填充社保号
					$("td[name='hosrMedical']").text(guahao.hosrMedical);
					// 填充联系电话
					$("td[name='hosrPhone']").text(guahao.hosrPhone);
					// 填充是否自费
					if(guahao.hosrSelfPrice == 0){
						// 是否自费：1免费 0自费
						$("td[name='hosrSelfPrice']").text("是")
					}else{
						$("td[name='hosrSelfPrice']").text("否")
					}
					// 计算年龄
					let year = parseInt(guahao.hosrIdcar.substr(6,4));
					let month = parseInt(guahao.hosrIdcar.substr(10,2));
					let day = parseInt(guahao.hosrIdcar.substr(12,2));
					let nowYear = new Date().getFullYear();
					let nowMoth = new Date().getMonth() + 1;
					let nowDay = new Date().getDate();
					if(nowMoth - month > 0){
						// 年龄即年份相减
						$("td[name='hosrAge'").text(nowYear - year);
					}else if(nowMoth - month < 0){
						// 年龄即年份相减再减一
						$("td[name='hosrAge'").text(nowYear - year - 1);
					}else if(nowDay - day >= 0){
						// 月分相等, 日相等或更大, 即刚好满岁或不超出一个月 -> 年龄即年份相减
						$("td[name='hosrAge'").text(nowYear - year);
					}else{
						// 今年生日没到 -> 年龄即年份相减再减一
						$("td[name='hosrAge'").text(nowYear - year);
					}
					// 计算性别
					// 计算男女 第17位奇数是男, 偶数是女
					if( guahao.hosrIdcar.substr(16,1)%2 == 0 ){
						$("td[name='hosrSex']").text("女");	// 女
					}else{
						$("td[name='hosrSex']").text("男");  // 男
					}
					// 填充职业
					$("td[name='hosrWork']").text(guahao.hosrWork);
					// 填充初复诊
					if( guahao.hosrLookDoctor == 0 ){
						// 初复诊： 0初诊 1复诊
						$("td[name='hosrLookDoctor']").text("初诊");
					}else{
						$("td[name='hosrLookDoctor']").text("复诊");
					}
					// 填充科室
					$("td[name='keshi']").text(guahao.keshi);
					// 填充医生
					$("td[name='doctor']").text(guahao.doctorName);
					// 填充备注
					$("td[name='hosrRemark']").text(guahao.hosrRemark);
				}else{
					layer.msg(data.msg, function(){});
				}
		    },
		    complete : function(xhr, status) {
		        myComplete(xhr, status);
		    }
		})
	}
	
    $(function () {
    	// 填充信息
    	queryMsg();
    	// 返回列表
    	$('#backid').click(function(){
    		window.location.href="index.html?pageNum=" + globalPageNum + "&pageSize=" + globalPageSize;
    	 });
    });
    </script>
</head>
<body>
<form action="index.html" method="post" class="definewidth m20">
<table class="table table-bordered table-hover definewidth m10">
    <tr>
        <td width="10%" class="tableleft">姓名</td>
        <td name="hosrName"></td>
    </tr>

    <tr>
        <td width="10%" class="tableleft">身份证号</td>
        <td name="hosrIdcar"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">挂号费</td>
        <td name="hosrRegPrice"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">社保号</td>
        <td name="hosrMedical"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">联系电话</td>
        <td name="hosrPhone"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">是否自费</td>
        <td name="hosrSelfPrice"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">性别</td>
        <td name="hosrSex"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">年龄</td>
        <td name="hosrAge"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">职业</td>
        <td name="hosrWork"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">初复诊</td>
        <td name="hosrLookDoctor"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">所挂科室</td>
        <td name="keshi"></td>
    </tr>
    <tr>
        <td width="10%" class="tableleft">指定医生</td>
        <td name="doctor"></td>
    </tr>
	<tr>
        <td width="10%" class="tableleft">备注</td>
        <td name="hosrRemark"></td>
	</tr>
    <tr>
        <td colspan="2">
			<center>
				<button type="button" class="btn btn-success" name="backid" id="backid">返回列表</button>
			</center
		</td>
    </tr>
</table>
</form>
</body>
</html>